		
		**********************************************************
		** File: cleaning_dpi.do								**
		** Paper: Human Trafficking Indicators: A New Dataset	**
		** Author: Richard Frank								**
		** Date: July 11, 2021									**
		** Task: Cleaning DPI									**
 		**********************************************************
 
		clear
		version 16.1
		set seed 1234
		set more off
		clear matrix
		clear mata

		cd "~"
		
		** data source: https://www.iadb.org/en/research-and-data/dpi2017
		
		use "DPI2017.dta"
		
		rename country Country
		run "cow.do"
		sort ccode
		tab Country if ccode==0
		drop if ccode==0
		order Country ccode
		rename Country country
		sort ccode year
		duplicates report ccode year
		drop if ccode==352 & ifs=="0"		
		drop if ifs=="YMD" & year>1989
		
		keep ccode year execrlc
		gen execleft=0
		replace execleft=1 if execrlc==3
		replace execleft=. if execrlc==.
		label var execleft "Chief exec party is left (DPI)"
		
		gen execright=0
		replace execright=1 if execrlc==1
		replace execright=. if execrlc==.
		label var execright "Chief exec party is right (DPI)"
					
		save "dpi2017 left right.dta", replace
		
